<template>
  <div class="page-wrap" style="height:100vh;">
    <mt-header fixed :title="$t('real_identity')">
        <router-link to="" slot="left" style="text-decoration: none;color: #fff;">
          <mt-button @click="$router.back(-1)" icon="back"></mt-button>
          </router-link>
    </mt-header>
    <div v-if="navs_s" class="tips">{{$t('submited_and_wait')}}</div>
    <div v-if="navs" style="margin-top: 80px;">
      <div v-if="show" style="padding: 20px; color: #FFFFFF; font-size: 20px;">{{$t('realname_approve_fail')}}</div>
      <div style="padding: 20px;">
        <mt-field :label="$t('realname')" v-model="form.real_name" :placeholder="$t('input_realname')" class="inouts"></mt-field>
        <mt-field :label="$t('id_number')" v-model="form.code" :placeholder="$t('input_id_number')" type="number" class="inouts"></mt-field>
        <mt-field :label="$t('bank_card')" v-model="form.bank_code" :placeholder="$t('input_bank_card')" type="number" class="inouts"></mt-field>
        <mt-field :label="$t('open_bank')" v-model="form.bank_name" :placeholder="$t('input_open_bank')" class="inouts"></mt-field>
        <mt-field :label="$t('open_branch_bank')" v-model="form.child_name" :placeholder="$t('input_open_branch_bank')" class="inouts"></mt-field>
      </div>
      <div class="sub" @click="sub()">
        {{$t('submit')}}
      </div>
    </div>
    <div v-if="navs_t">
      <div style="margin-top: 80px;padding: 20px;">
        <mt-field :label="$t('realname')" v-model="param.real_name" disabled="disabled" class="inouts"></mt-field>
        <mt-field :label="$t('id_number')" v-model="param.code" disabled="disabled" class="inouts"></mt-field>
        <mt-field :label="$t('bank_card')" v-model="param.bank_code" disabled="disabled" type="number" class="inouts"></mt-field>
        <mt-field :label="$t('open_bank')" v-model="param.bank_name" disabled="disabled" class="inouts"></mt-field>
        <mt-field :label="$t('open_branch_bank')" v-model="param.child_name" disabled="disabled" class="inouts"></mt-field>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    created() {

    },
    data() {
      return {
        param: [], //信息
        form: {
          real_name: '',
          code: '',
          bank_name: '',
          bank_code: '',
          child_name:''
        },
        navs: false,
        navs_s: false,
        navs_t: false,
        show: false,
      };
    },
    mounted() {
      this.authentication()
    },
    methods: {
      sub() {
        if (this.form.real_name == '') {
          this.$layer.msg(this.$t('input_realname'));
          return;
        }
        if (this.form.code == '') {
          this.$layer.msg(this.$t('input_bank_card'));
          return;
        }
        if (this.form.bank_name == '') {
          this.$layer.msg(this.$t('input_open_bank'));
          return;
        }
        if (this.form.bank_code == '') {
          this.$layer.msg(this.$t('input_bank_card'));
          return;
        }
        if (this.form.child_name == '') {
          this.$layer.msg(this.$t('input_open_branch_bank'));
          return;
        }
        this.$post('addons/tf-futures/member/upload', this.form).then(res => {
          if (res.code == 200) {
            this.$layer.msg(this.$t('submited_and_wait'))
            this.authentication()
            this.form.real_name = '';
            this.form.code = '';
            this.form.bank_name = '';
            this.form.bank_code = '';
            this.form.child_name = '';
            this.navs = false;
            this.navs_s = false;
            this.navs_t = false;
            this.show = false;
          } else {
            this.$layer.msg(res.message || this.$t('submit_fail'))
          }
        });
      },
      //获取认证信息
      authentication() {
        this.$get('addons/tf-futures/member/identity-status').then(res => {
          if (res.code == 200) {
            if (res.data.length == 0) {
              this.navs = !this.navs
            } else if (res.data.status == this.$t('no_pass')) {
              this.navs = !this.navs
              this.show = !this.show
            } else if (res.data.status == this.$t('waitting_review')) {
              this.navs_s = !this.navs_s
            } else {
              this.navs_t = !this.navs_t
              this.param = res.data
            }
          } else {
            this.navs = !this.navs
          }
        });
      }
    }
  };
</script>
<style scoped>
  .tips {
    margin-top: 80px;
    padding: 20px;
    color: #FFFFFF;
    font-size: 30px;
  }

  .inouts {
    width: 100%;
    height: 1.2rem;
    border: 1px solid #333;
    background: #414141;
  }

  .page-wrap>>>.mint-field .mint-cell-title {
    width: 150px;
    color: #ffffff;
  }

  .sub {
    margin: 50px;
    background: #409DE5;
    color: #ffffff;
    text-align: center;
    padding: 20px;
    font-size: 35px;
  }
</style>
